package com.homson.coreservice.serviceapp.agent;

import com.homson.coreservice.serviceapi.query.AiAgentApi;
import com.homson.coreservice.servicecommon.request.RequestParameter;
import com.homson.coreservice.servicecommon.response.EntityResponse;
import com.homson.servicedomain.domain.agent.AgentModelCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

import static com.homson.coreservice.servicecommon.enumeration.ResponseCodeEnum.SUCCESS;

@Service
@Slf4j
public class AiAgentService implements AiAgentApi {
    
    @Autowired
    private AgentModelCommand agentModelCommand;
    
    @Override
    public EntityResponse<String> simpleChat(RequestParameter<String> request) {
       // log.info("AiAgentService#simpleChat input:{}",request);
        String input = request.getBody();
        if (Objects.isNull(input)) {
            return EntityResponse.fail("无输入");
        }
        String answer = agentModelCommand.simpleChat(input);
    //    log.info("AiAgentService#simpleChat out:{}",answer);
        return new EntityResponse<>(SUCCESS, "success", answer);
    }
}
